<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
  <title>LCOV - mbi.info - /home/jkbs/src/zpr/imageeditor/MBI_svn/algorithm/Path.cpp</title>
  <link rel="stylesheet" type="text/css" href="../../../../../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
        <tr>
          <td class="headerItem" width="20%">Current&nbsp;view:</td>
          <td class="headerValue" width="80%" colspan=4><a href="../../../../../../../index.html">directory</a> - <a href="index.html">home/jkbs/src/zpr/imageeditor/MBI_svn/algorithm</a> - Path.cpp</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Test:</td>
          <td class="headerValue" width="80%" colspan=4>mbi.info</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Date:</td>
          <td class="headerValue" width="20%">2010-01-23</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Instrumented&nbsp;lines:</td>
          <td class="headerValue" width="20%">76</td>
        </tr>
        <tr>
          <td class="headerItem" width="20%">Code&nbsp;covered:</td>
          <td class="headerValue" width="20%">89.5 %</td>
          <td width="20%"></td>
          <td class="headerItem" width="20%">Executed&nbsp;lines:</td>
          <td class="headerValue" width="20%">68</td>
        </tr>
        </table>
      </td>
    </tr>
    <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td><pre class="source">
<span class="lineNum">       1 </span>                : #include &lt;algorithm&gt;
<span class="lineNum">       2 </span>                : #include &lt;iostream&gt;
<span class="lineNum">       3 </span>                : #include &quot;Path.hpp&quot;
<span class="lineNum">       4 </span>                : 
<span class="lineNum">       5 </span>                : //using namespace boost;
<span class="lineNum">       6 </span>                : using namespace std;
<span class="lineNum">       7 </span>                : 
<span class="lineNum">       8 </span><span class="lineCov">              2 : Path::Path() {</span>
<span class="lineNum">       9 </span><span class="lineCov">              2 :         path_ = PMatrixType(new MatrixType);</span>
<span class="lineNum">      10 </span><span class="lineCov">              2 :         firstAlignment_ = PSequence(new Sequencee);</span>
<span class="lineNum">      11 </span><span class="lineCov">              2 :         secondAlignment_ = PSequence(new Sequencee);</span>
<span class="lineNum">      12 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">      13 </span>                : 
<span class="lineNum">      14 </span><span class="lineCov">              2 : Path::~Path() {</span>
<span class="lineNum">      15 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">      16 </span>                : 
<span class="lineNum">      17 </span><span class="lineCov">              2 : void Path::findMaxValue(const PMatrixType matrix) {</span>
<span class="lineNum">      18 </span><span class="lineCov">              2 :         if(matrix == NULL)</span>
<span class="lineNum">      19 </span><span class="lineNoCov">              0 :                 throw logic_error(&quot;No matrix in: Path::findMaxValue&quot;);</span>
<span class="lineNum">      20 </span>                : 
<span class="lineNum">      21 </span><span class="lineCov">              2 :         ArrayType tmpMaxElement;</span>
<span class="lineNum">      22 </span><span class="lineCov">              2 :         ArrayType colIndex;</span>
<span class="lineNum">      23 </span>                : 
<span class="lineNum">      24 </span><span class="lineCov">              2 :         ConstItr2D rowBeginItr = matrix-&gt;begin();</span>
<span class="lineNum">      25 </span><span class="lineCov">              2 :         ConstItr2D rowEndItr = matrix-&gt;end();</span>
<span class="lineNum">      26 </span>                : 
<span class="lineNum">      27 </span><span class="lineCov">              2 :         ConstItr1D tmpItr;</span>
<span class="lineNum">      28 </span><span class="lineCov">             12 :         for(ConstItr2D i = rowBeginItr; i != rowEndItr; ++i) {</span>
<span class="lineNum">      29 </span><span class="lineCov">             10 :                 ConstItr1D colBeginItr = i-&gt;begin();</span>
<span class="lineNum">      30 </span><span class="lineCov">             10 :                 ConstItr1D colEndItr = i-&gt;end();</span>
<span class="lineNum">      31 </span>                : 
<span class="lineNum">      32 </span><span class="lineCov">             10 :                 tmpItr = max_element(colBeginItr, colEndItr);</span>
<span class="lineNum">      33 </span>                : 
<span class="lineNum">      34 </span><span class="lineCov">             10 :                 tmpMaxElement.push_back(*tmpItr);</span>
<span class="lineNum">      35 </span><span class="lineCov">             10 :                 colIndex.push_back(tmpItr - colBeginItr);</span>
<span class="lineNum">      36 </span>                :         }
<span class="lineNum">      37 </span>                :         
<span class="lineNum">      38 </span><span class="lineCov">              2 :         ConstItr1D vItr = max_element(tmpMaxElement.begin(), tmpMaxElement.end());</span>
<span class="lineNum">      39 </span>                : 
<span class="lineNum">      40 </span><span class="lineCov">              2 :         ArrayType tmp;</span>
<span class="lineNum">      41 </span><span class="lineCov">              2 :         tmp.push_back(vItr - tmpMaxElement.begin());</span>
<span class="lineNum">      42 </span><span class="lineCov">              2 :         tmp.push_back(colIndex[tmp[0]]);</span>
<span class="lineNum">      43 </span>                :         
<span class="lineNum">      44 </span><span class="lineCov">              2 :         path_-&gt;push_back(tmp);</span>
<span class="lineNum">      45 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">      46 </span>                : 
<span class="lineNum">      47 </span><span class="lineCov">              2 : void Path::findPath(const PMatrixType matrix) {</span>
<span class="lineNum">      48 </span><span class="lineCov">              2 :         if(matrix == NULL)</span>
<span class="lineNum">      49 </span><span class="lineNoCov">              0 :                 throw logic_error(&quot;No matrix in: Path::findPath&quot;);</span>
<span class="lineNum">      50 </span>                : 
<span class="lineNum">      51 </span><span class="lineCov">              2 :         findMaxValue(matrix);</span>
<span class="lineNum">      52 </span>                : 
<span class="lineNum">      53 </span><span class="lineCov">              2 :         int row = (*path_)[0][0];</span>
<span class="lineNum">      54 </span><span class="lineCov">              2 :         int col = (*path_)[0][1];</span>
<span class="lineNum">      55 </span><span class="lineCov">              2 :         ArrayType tmp;</span>
<span class="lineNum">      56 </span>                :         
<span class="lineNum">      57 </span><span class="lineCov">              8 :         for(int i = 1; row != 0 &amp;&amp; col != 0; ++i) {</span>
<span class="lineNum">      58 </span><span class="lineCov">              8 :                 tmp.clear();</span>
<span class="lineNum">      59 </span><span class="lineCov">              8 :                 if((*matrix)[row - 1][col - 1] == 0)</span>
<span class="lineNum">      60 </span><span class="lineCov">              2 :                         break;</span>
<span class="lineNum">      61 </span>                : 
<span class="lineNum">      62 </span><span class="lineCov">              6 :                 if((*matrix)[row - 1][col - 1] &gt; (*matrix)[row][col - 1] &amp;&amp;</span>
<span class="lineNum">      63 </span>                :                         (*matrix)[row - 1][col - 1] &gt; (*matrix)[row - 1][col]) {
<span class="lineNum">      64 </span><span class="lineCov">              3 :                         tmp.push_back(--row);</span>
<span class="lineNum">      65 </span><span class="lineCov">              3 :                         tmp.push_back(--col);</span>
<span class="lineNum">      66 </span><span class="lineCov">              3 :                         path_-&gt;push_back(tmp);       // idzie w gore i lewo</span>
<span class="lineNum">      67 </span>                :                 }
<span class="lineNum">      68 </span>                :                 else {
<span class="lineNum">      69 </span><span class="lineCov">              3 :                         if((*matrix)[row][col - 1] &gt; (*matrix)[row - 1][col]) {</span>
<span class="lineNum">      70 </span><span class="lineCov">              3 :                                 tmp.push_back(row);</span>
<span class="lineNum">      71 </span><span class="lineCov">              3 :                                 tmp.push_back(--col);</span>
<span class="lineNum">      72 </span><span class="lineCov">              3 :                                 path_-&gt;push_back(tmp);       // idzie w lewo</span>
<span class="lineNum">      73 </span>                :                         } 
<span class="lineNum">      74 </span>                :                         else {
<span class="lineNum">      75 </span><span class="lineNoCov">              0 :                                 tmp.push_back(--row);</span>
<span class="lineNum">      76 </span><span class="lineNoCov">              0 :                                 tmp.push_back(col);</span>
<span class="lineNum">      77 </span><span class="lineNoCov">              0 :                                 path_-&gt;push_back(tmp);       // idzie w gore</span>
<span class="lineNum">      78 </span>                :                         }
<span class="lineNum">      79 </span>                :                 }
<span class="lineNum">      80 </span><span class="lineCov">              2 :         }</span>
<span class="lineNum">      81 </span>                : /*
<span class="lineNum">      82 </span>                :         for(int i = 0; i &lt; path_-&gt;size(); ++i) {
<span class="lineNum">      83 </span>                :                 cout &lt;&lt; (*path_)[i][0] &lt;&lt; ' ' &lt;&lt; (*path_)[i][1] &lt;&lt; endl;
<span class="lineNum">      84 </span>                :         }*/
<span class="lineNum">      85 </span><span class="lineCov">              2 : }</span>
<span class="lineNum">      86 </span>                : 
<span class="lineNum">      87 </span><span class="lineCov">              1 : void Path::reconstructAlignment(const PSequence seq1, const PSequence seq2) {</span>
<span class="lineNum">      88 </span><span class="lineCov">              1 :         if (seq1 == NULL || seq2 == NULL)</span>
<span class="lineNum">      89 </span><span class="lineNoCov">              0 :                 throw logic_error(&quot;No sequence available in: Path::reconstructAlignment&quot;);</span>
<span class="lineNum">      90 </span>                : 
<span class="lineNum">      91 </span><span class="lineCov">              1 :         int i = 0;</span>
<span class="lineNum">      92 </span><span class="lineCov">              1 :         std::string tmpAlig1, tmpAlig2;</span>
<span class="lineNum">      93 </span>                : 
<span class="lineNum">      94 </span><span class="lineCov">              1 :         string::iterator firstItr = tmpAlig1.begin();</span>
<span class="lineNum">      95 </span><span class="lineCov">              1 :         string::iterator secondItr = tmpAlig2.begin();</span>
<span class="lineNum">      96 </span>                : 
<span class="lineNum">      97 </span><span class="lineCov">              1 :         tmpAlig1.insert(firstItr, seq1-&gt;getSequenceElement((*path_)[i][0] - 1));</span>
<span class="lineNum">      98 </span><span class="lineCov">              1 :         tmpAlig2.insert(secondItr, seq2-&gt;getSequenceElement((*path_)[i][1] - 1));</span>
<span class="lineNum">      99 </span>                :         
<span class="lineNum">     100 </span><span class="lineCov">              1 :         int endPath = path_-&gt;size();</span>
<span class="lineNum">     101 </span><span class="lineCov">              4 :         for(int i = 1; i &lt; endPath; ++i) {</span>
<span class="lineNum">     102 </span><span class="lineCov">              3 :                 firstItr = tmpAlig1.begin();</span>
<span class="lineNum">     103 </span><span class="lineCov">              3 :                 secondItr = tmpAlig2.begin();</span>
<span class="lineNum">     104 </span>                : 
<span class="lineNum">     105 </span><span class="lineCov">              3 :                 if((*path_)[i-1][0] == (*path_)[i][0]) {</span>
<span class="lineNum">     106 </span><span class="lineCov">              1 :                         tmpAlig1.insert(firstItr, '-');</span>
<span class="lineNum">     107 </span><span class="lineCov">              1 :                         tmpAlig2.insert(secondItr, seq2-&gt;getSequenceElement((*path_)[i][1] - 1));</span>
<span class="lineNum">     108 </span>                :                 }
<span class="lineNum">     109 </span><span class="lineCov">              2 :                 else if((*path_)[i-1][1] == (*path_)[i][1]) {</span>
<span class="lineNum">     110 </span><span class="lineNoCov">              0 :                         tmpAlig1.insert(firstItr, seq1-&gt;getSequenceElement((*path_)[i][0] - 1));</span>
<span class="lineNum">     111 </span><span class="lineNoCov">              0 :                         tmpAlig2.insert(secondItr, '-');</span>
<span class="lineNum">     112 </span>                :                 }
<span class="lineNum">     113 </span>                :                 else {
<span class="lineNum">     114 </span><span class="lineCov">              2 :                         tmpAlig1.insert(firstItr, seq1-&gt;getSequenceElement((*path_)[i][0] - 1));</span>
<span class="lineNum">     115 </span><span class="lineCov">              2 :                         tmpAlig2.insert(secondItr, seq2-&gt;getSequenceElement((*path_)[i][1] - 1));</span>
<span class="lineNum">     116 </span>                :                 }
<span class="lineNum">     117 </span>                :         }
<span class="lineNum">     118 </span>                : 
<span class="lineNum">     119 </span><span class="lineCov">              1 :         firstAlignment_-&gt;setSequence(tmpAlig1);</span>
<span class="lineNum">     120 </span><span class="lineCov">              1 :         secondAlignment_-&gt;setSequence(tmpAlig2);</span>
<span class="lineNum">     121 </span>                : 
<span class="lineNum">     122 </span><span class="lineCov">              1 :         return;</span>
<span class="lineNum">     123 </span><span class="lineCov">              3 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
  <tr><td class="ruler"><img src="../../../../../../../glass.png" width=3 height=3 alt=""></td></tr>
  <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
  </table>
  <br>

</body>
</html>
